function ListNode(val) {
    this.val = val;
    this.next = null
}
/**
 * @param {ListNode} head
 * @param {number} k
 * @return {ListNode}
 */
var getKthFromEnd = function(head, k) {
    // let p = head
    // let count = 0;
    // while (p != null) {
    //     p = p.next
    //     count++
    // }
    // let q = head;
    // let index = 0;
    // while (index != count - k) {
    //     q = q.next
    //     index++
    // }
    // return q
    p = k;
};
var getKthFromEnd = function(head, k) {
    let p

}
function dfs(head) {


}
//
let head = new ListNode(1)
var p
var dfs = function (head) {
    if (head.next == null) {
        p--
        return head
    }
    node = dfs(head.next)
    p--
    if (p == 0) {
        return head
    }
    return node
}

var reverseList = function(head) {
    let newHead = new ListNode(-1)
    let cur = head
    let temp
    while (cur != null) {
        temp = cur.next
        cur.next = newHead.next
        newHead.next = cur
        cur = temp
    }
    return newHead.next
};